package com.erytech.linktalk.dao.ibatis;

import java.util.List;

import com.erytech.linktalk.dao.UserDao;
import com.erytech.linktalk.dao.domain.User;
import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.template.SqlMapDaoTemplate;

public class SqlMapUserDao extends SqlMapDaoTemplate implements UserDao {

	public SqlMapUserDao(DaoManager daoManager) {
		super(daoManager);
	}

	public User getUser(String id) {
		return (User) queryForObject("getUserById", id);
	}

	public List getUserList() {
		return queryForList("getUserList");
	}

	public void insertUser(User user) {
		insert("insertUser", user);
	}

	public void deleteUser(String id) {
		delete("deleteUser", id);
	}

	public boolean hasUser(String id) {
		User user = getUser(id);
		return user != null;
	}

	public List getUsersInRoom(String roomId) {
		return queryForList("getUsersInRoom", roomId);
	}

	public void updateUser(User user) {
		update("updateUser", user);
	}

	public void deleteAllUsers() {
		delete("deleteAllUsers");
	}

}
